import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:mall/constant/app_colors.dart';

class ChangNameWidget extends StatefulWidget {
  const ChangNameWidget({super.key, this.name});

  final String? name;

  @override
  State<ChangNameWidget> createState() => _ChangNameWidgetState();
}

class _ChangNameWidgetState extends State<ChangNameWidget> {

 late final textC = TextEditingController(text: widget.name);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        padding: EdgeInsets.all(32),
        width: 300,
        height: 214,
        decoration: BoxDecoration(
          color: AppColors.C_FFFFFF,
          borderRadius: BorderRadius.all(Radius.circular(30)),
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            //标题
            Text(
              '修改昵称',
              style: TextStyle(color: AppColors.C_222222, fontSize: 18, fontWeight: FontWeight.bold),
            ),

            //输入框
            Container(
              height: 40,
              decoration: BoxDecoration(
                color: Color(0xfff7f7f7),
                borderRadius: BorderRadius.all(Radius.circular(10)),
              ),
              child: TextField(
                controller: textC,
                maxLength: 10,
                style: TextStyle(
                  color: AppColors.C_222222,
                  fontSize: 12,
                ),
                decoration: InputDecoration(
                  contentPadding: EdgeInsets.symmetric(horizontal: 15, vertical: 11),
                  hintText: '请输入昵称,不超过10个字',
                  counterText: '',
                  hintStyle: TextStyle(
                    color: AppColors.C_999999,
                    fontSize: 12,
                  ),
                  border: InputBorder.none,
                  isDense: true,
                ),
              ),
            ),

            //按钮
            Row(
              children: [
                Expanded(
                  flex: 1,
                  child: InkWell(
                    onTap: () => Get.back(),
                    child: Container(
                      height: 38,
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        color: Color(0xfff7f7f7),
                        borderRadius: BorderRadius.all(Radius.circular(19)),
                      ),
                      child: Text(
                        '取消',
                        style: TextStyle(color: AppColors.C_222222, fontSize: 15),
                      ),
                    ),
                  ),
                ),
                SizedBox(width: 20),
                Expanded(
                  flex: 1,
                  child: InkWell(
                    onTap: () {
                      //保存
                    },
                    child: Container(
                      height: 38,
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        color: AppColors.C_FD2C55,
                        borderRadius: BorderRadius.all(Radius.circular(19)),
                      ),
                      child: Text(
                        '保存',
                        style: TextStyle(color: AppColors.C_222222, fontSize: 15),
                      ),
                    ),
                  ),
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}
